#include<bits/stdc++.h>
#define rep(l,r,i) for(int i=l;i<=r;i++) 
#define per(l,r,i) for(int i=l;i>=r;i--) 
#define pi pair<int,int> 
#define mk make_pair 
using namespace std;
#define int long long 
#define Maxn 5005 
int n,k,a[Maxn],b[Maxn],sum[Maxn],R[Maxn],f[2505][Maxn];
int calc(int l,int r) {
    return sum[r]-sum[l-1];
}
void Main() {
    cin>>n>>k;
    rep(0,n+1,i)rep(0,Maxn-1,j)f[i][j] = 0;
    rep(1,n-1,i)cin>>a[i]; a[0] = a[n] = Maxn-1;
    rep(1,k,i)cin>>b[i],sum[i] = sum[i-1]+b[i];
    rep(1,n,i)R[i] = calc(max(1ll,k-n+i),min(k,i));
    // cout<<"[";rep(1,n,i)cout<<R[i]<<" ";cout<<"]\n";
    rep(1,n,i) {
        // cout<<"{";
        rep(0,min(a[i-1],a[i]),j) {
            int res = 0;
            rep(0,a[i-1]-j,l)res = max(res,f[i-1][l]);
            f[i][j] = res+j*R[i];
            // cout<<f[i][j]<<" ";
        }
        // cout<<"}\n";
    } int ans = 0;
    rep(0,a[n-1],i)ans = max(ans,f[n][i]);
    cout<<ans<<"\n";
    return void();
}
signed main()
{
    freopen("festival.in","r",stdin);
    freopen("festival.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int c,t; cin>>c>>t;
    while(t --)Main();
    return 0;
}